$(function () {
    layui.use('carousel', function () {
        // 轮播模块
        var carousel = layui.carousel
        // 加载轮播图数据
        function loadSwiperList() {
            $.ajax({
                type: 'get',
                url: 'http://localhost:8888/api/swipers',
                success: function (res) {
                    if (res.status === 0) {
                        $("#kr_carousel ul").empty();
                        let htmlStr = template("carouselLi",res);
                        $("#kr_carousel ul").html(htmlStr);
                        // 轮播交互
                        carousel.render({
                            elem: '#kr_carousel',
                            width: 720,
                            height: 300,
                            interval: 3000
                        })
                    }
                }
            })
        }
        loadSwiperList();
    });

    // 加载友情链接
    $.ajax({
        type:'get',
        url:'http://localhost:8888/api/links',
        success: function (res) {
            if (res.status === 0) {
                $(".kr_collaborator").empty();
                let htmlStr = template("kr_collaboratorDd",res);
                $(".kr_collaborator").html(htmlStr);
            }
        }
    })
})